<?php
/**
 * 后台验证权限中间件
 */
namespace app\admin\middleware;
use think\facade\Db;

class Check
{
    public function handle($request, \Closure $next)
    {

        // 加载插件函数
        include_once  ROOT_PATH.'extend/helper/helper.php';

        $pathinfo = explode('/',$request->pathinfo());
		$controller = !empty($pathinfo[0]) ? str_replace('.html','',$pathinfo[0]) : 'Index';
		$action = !empty($pathinfo[1]) ? str_replace('.html','',$pathinfo[1]) : 'index';
    	
        $admin = session('admin');
        if (!$admin && ( $controller <> 'login' )) {
        	return redirect(url('login/index'));
        }

        return $next($request);
    }
}
